﻿using Furion.DependencyInjection;
using Queer.Entity;
using Queer.IBusiness.OrganizationManage;
using Queer.IService.OrganizationManage;
using Queer.Model.Param.OrganizationManage;
using Queer.Util;
using Queer.Util.Model;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Queer.Business.OrganizationManage
{
    /// <summary>
    /// 创 建：
    /// 日 期：2021-04-07 16:44
    /// 描 述：机构管理业务类
    /// </summary>

    public class OrganizationsBLL : IOrganizationsBLL, ITransient
    {
        private readonly IOrganizationsService _organizationsService;

        public OrganizationsBLL(IOrganizationsService organizationsService)
        {
            _organizationsService = organizationsService;
        }

        #region 获取数据

        public async Task<TData<List<OrganizationsEntity>>> GetList(OrganizationsListParam param)
        {
            TData<List<OrganizationsEntity>> obj = new TData<List<OrganizationsEntity>>();
            obj.Data = await _organizationsService.GetList(param);
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<OrganizationsEntity>>> GetPageList(OrganizationsListParam param, Pagination pagination)
        {
            TData<List<OrganizationsEntity>> obj = new TData<List<OrganizationsEntity>>();
            obj.Data = await _organizationsService.GetPageList(param, pagination);
            obj.Total = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<OrganizationsEntity>> GetEntity(long id)
        {
            TData<OrganizationsEntity> obj = new TData<OrganizationsEntity>();
            obj.Data = await _organizationsService.GetEntity(id);
            obj.Tag = 1;
            return obj;
        }

        #endregion

        #region 提交数据

        public async Task<TData<string>> SaveForm(OrganizationsEntity entity)
        {
            TData<string> obj = new TData<string>();
            await _organizationsService.SaveForm(entity);
            obj.Data = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await _organizationsService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }

        #endregion
    }
}